/**
 * Created by yuris on 15.01.15.
 */
package tests {



import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Rectangle;
import flash.text.TextField;

import starling.core.Starling;

[SWF(height = 800, width = 1000, frameRate = 60)]
public class Test_interface extends flash.display.Sprite {
    public function Test_interface() {
        if(stage){
            this._init()}
        else {
            this.addEventListener(Event.ADDED_TO_STAGE, this._onAddedToStage)
        }
    }
    private function _onAddedToStage(event:Event):void {
        this.removeEventListener(Event.ADDED_TO_STAGE, this._onAddedToStage);
        this._init();
    }
    private var _starling:Starling = null;
    private function _init():void {
        this._starling = new Starling(Test_Starling_Module,stage,new Rectangle(0,0,stage.stageWidth,stage.stageHeight));
        this._starling.showStats = true;
        this._starling.start();
    }
}

}


import InterfaceObjects.BottomPanel.BottomPanel;
import InterfaceObjects.BottomPanel.WarehouseItem;
import InterfaceObjects.ButtonLong;
import InterfaceObjects.ButtonSmall;
import InterfaceObjects.OrdetProductWindow.OrderProductItem;
import InterfaceObjects.AbstractTabWindow;
import InterfaceObjects.OrdetProductWindow.OrderProductWindow;

import feathers.controls.Button;
import feathers.controls.Label;
import feathers.controls.Label;
import feathers.controls.ScrollBar;
import feathers.controls.ScrollContainer;
import feathers.controls.text.BitmapFontTextRenderer;
import feathers.text.BitmapFontTextFormat;

import starling.display.Image;
import starling.display.Sprite;
import starling.text.TextField;

import treefortress.textureutils.AtlasBuilder;

import treefortress.textureutils.AtlasBuilder;

class Test_Starling_Module extends  Sprite{
    public function Test_Starling_Module() {
        GraphicFactory.init(this._onFactoryInit)
    }

    private function _onFactoryInit():void {
        var _imageBuf:Image = GraphicFactory.getImageForRender("Interface/Buttons/button_1_small_blue");
        _imageBuf.x = _imageBuf.y = 100;
        addChild(_imageBuf);

        //var v:Vector.<Image> = new Vector.<Image>(10);
        //trace(v[11]);

        //this._testLongButton();

        //this._testSmallButton();

        //this._testLabels()

        //this._testBottomBar();

        //this._testOrderProductWindow();

    }

    private function _testOrderProductWindow():void {
        var _orderProductWindowData:Array = [
            {icon:"Interface/Icons/Products/icon_Banana", description:"Banana\n   Demand: 10\n   Cost: 100$\n   Deliver time: 72h"},
            {icon:"Interface/Icons/Products/icon_ToothPaste", description:"Tooth paste\n   Demand: 100\n   Cost: 1900$\n   Deliver time: 172h"},
            {icon:"Interface/Icons/Products/icon_Water_1", description:"Water 5L\n   Demand: 130\n   Cost: 1100$\n   Deliver time: 72h"},
            {icon:"Interface/Icons/Products/icon_Orange", description:"Oranges\n   Demand: 10\n   Cost: 100$\n   Deliver time: 72h"},
            {icon:"Interface/Icons/Products/icon_Juice_1", description:"Orange juice\n   Demand: 10\n   Cost: 100$\n   Deliver time: 72h"},
            {icon:"Interface/Icons/Products/icon_Cola", description:"Cola-Cola\n   Demand: 10\n   Cost: 100$\n   Deliver time: 72h"},
            {icon:"Interface/Icons/Products/icon_Beer", description:"Heinekeken\n   Demand: 10\n   Cost: 100$\n   Deliver time: 72h"}
        ]

        var _orderProductWindow:OrderProductWindow = new OrderProductWindow("Order super product", ["Food","Cosmetic","Electric"]);
        _orderProductWindow.x = 400;
        _orderProductWindow.y = 300;

        _orderProductWindow.addTabContentMultiData(1,_orderProductWindowData.concat(_orderProductWindowData.concat(_orderProductWindowData)));
        _orderProductWindow.addTabContentMultiData(2,_orderProductWindowData);
        _orderProductWindow.showTab(1);
        addChild(_orderProductWindow);

        _orderProductWindow.width = 590;
        _orderProductWindow.height = 540;

        var _item:OrderProductItem = new OrderProductItem("Interface/Icons/Products/icon_Banana", "Banana\n   Demand: 10\n   Cost: 100$\n   Deliver time: 72h");
        _item.x = 450;
        _item.y = 250;
        //addChild(_item);


        //var _image:Image = GraphicFactory.getImageByName("Interface/Skins/scroll_bar_vertical");
        //addChild(_image);



    }

    private function _testBottomBar():void {

        var _wareHouseData:Array = [
            {product:"Interface/Icons/Products/icon_Banana", amount:50},
            {product:"Interface/Icons/Products/icon_ToothPaste", amount:150, deliverSecondsRest:3456},
            {product:"Interface/Icons/Products/icon_Water_1", amount:20, deliverSecondsRest:12},
            {product:"Interface/Icons/Products/icon_Orange", amount:11, deliverSecondsRest:375},
            {product:null, amount:10},
            {product:"Interface/Icons/Products/icon_Juice_1", amount:10},
            {product:"Interface/Icons/Products/icon_Cola", amount:900},
            {product:"Interface/Icons/Products/icon_Beer", amount:899}
        ]


        var socialDataRaw:Object = {
            "data": [
                {
                    "installed": true,
                    "gender": "male",
                    "id": "100002511257981",
                    "picture": {
                        "data": {
                            "is_silhouette": false,
                            "url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn2/v/t1.0-1/p50x50/11483_575069589253411_1858891509_n.jpg?oh=923c14d46b1bcb85933ab2a6dc3cdcb0&oe=556182B0&__gda__=1431579533_1b60aef9138c58b39965fed8732bbdd4"
                        }
                    },
                    first_name:"Johnny",
                    picture_url: "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn2/v/t1.0-1/p50x50/11483_575069589253411_1858891509_n.jpg?oh=923c14d46b1bcb85933ab2a6dc3cdcb0&oe=556182B0&__gda__=1431579533_1b60aef9138c58b39965fed8732bbdd4"

                },
                {
                    "installed": true,
                    "gender": "male",
                    "id": "712074798886668",
                    "picture": {
                        "data": {
                            "is_silhouette": false,
                            "url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfp1/v/t1.0-1/p50x50/10390271_743896732371141_4052853514138096927_n.jpg?oh=0ba0e02bef9f7901a750b3dfe37f15a9&oe=555A553B&__gda__=1432890717_53cb730730c15a5cd537a171c4c1242d"
                        }
                    },
                    first_name:"Robert",
                    "picture_url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfp1/v/t1.0-1/p50x50/10390271_743896732371141_4052853514138096927_n.jpg?oh=0ba0e02bef9f7901a750b3dfe37f15a9&oe=555A553B&__gda__=1432890717_53cb730730c15a5cd537a171c4c1242d"

                },
                {
                    "installed": true,
                    "gender": "male",
                    "id": "100002675058893",
                    "picture": {
                        "data": {
                            "is_silhouette": false,
                            "url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfa1/v/t1.0-1/c66.50.828.828/s50x50/406594_358770434222122_406349789_n.jpg?oh=0e640eeb6396936442e7484f8b9921c4&oe=5558A588&__gda__=1432837316_f2778f78bada12d0a34a2d564fa21f93"
                        }
                    },
                    first_name:"Bill",
                    "picture_url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfa1/v/t1.0-1/c66.50.828.828/s50x50/406594_358770434222122_406349789_n.jpg?oh=0e640eeb6396936442e7484f8b9921c4&oe=5558A588&__gda__=1432837316_f2778f78bada12d0a34a2d564fa21f93"

                }
            ]
        }





        var _bottomPanel:BottomPanel = new BottomPanel();
       // _bottomPanel.setWarehouseContent(_wareHouseData.concat(_wareHouseData).concat(_wareHouseData));
        _bottomPanel.setSocialContent((socialDataRaw.data).concat((socialDataRaw.data)).concat((socialDataRaw.data)).concat((socialDataRaw.data)));
        _bottomPanel.y = this.stage.stageHeight;
        _bottomPanel.x = this.stage.stageWidth/2;
        addChild(_bottomPanel);

        _bottomPanel.showSocialItems();
       // _bottomPanel.showWarehouse();



    }

    private function _testLabels():void {
        var _bftr:BitmapFontTextRenderer = new BitmapFontTextRenderer();
        _bftr.textFormat =  new BitmapFontTextFormat("ComicDB");

        var _label:Label = new Label();
        _label.text = "LABEL test";
        _label.x = 300
        _label.y = 100;
        _label.textRendererProperties.useSeparateBatch = false;
        _label.textRendererProperties.textFormat = new BitmapFontTextFormat("ComicDB", 20)

        addChild(_label);

        _label = new Label();
        _label.text = "LABEL test 2";
        _label.x = 300
        _label.y = 200;
        _label.textRendererProperties.useSeparateBatch = false;
        _label.textRendererProperties.textFormat = new BitmapFontTextFormat("ComicDB")
        addChild(_label);
    }

    private function _testSmallButton():void {
        var _button:Button = new ButtonSmall(ButtonSmall.ORANGE_TYPE,ButtonSmall.SIGN_SHOP_BASKET);
        _button.x = 100;
        _button.y = 100;
        addChild(_button);

        _button = new ButtonSmall(ButtonSmall.RED_TYPE,ButtonSmall.SIGN_CROSS);
        _button.x = 150;
        _button.y = 150;
        addChild(_button);
        _button = new ButtonSmall(ButtonSmall.RED_TYPE,ButtonSmall.SIGN_CROSS);
        _button.x = 200;
        _button.y = 150;
        _button.width = _button.height = 35;
        addChild(_button);

        _button = new ButtonSmall(ButtonSmall.GREEN_TYPE,ButtonSmall.SIGN_ARRAY);
        _button.x = 100;
        _button.y = 150;
        addChild(_button);

        _button = new ButtonSmall(ButtonSmall.GREEN_TYPE,ButtonSmall.SIGN_BUILD);
        _button.x = 100;
        _button.y = 200;
        addChild(_button);

        _button = new ButtonSmall(ButtonSmall.GREEN_TYPE,ButtonSmall.SIGN_GEAR);
        _button.x = 100;
        _button.y = 250;
        addChild(_button);


        _button = new ButtonSmall(ButtonSmall.GREEN_TYPE,ButtonSmall.SIGN_PAINT);
        _button.x = 100;
        _button.y = 300;
        addChild(_button);

        _button = new ButtonSmall(ButtonSmall.GREEN_TYPE,ButtonSmall.SIGN_OK);
        _button.x = 100;
        _button.y = 350;
        addChild(_button);

    }

    private function _testLongButton():void {
        var _button:Button = new ButtonLong(ButtonLong.GREEN_TYPE);
        _button.x = 0;
        _button.y = 0;
        _button.label = "Shop";
        addChild(_button);

        _button = new ButtonLong(ButtonLong.GREEN_TYPE);
        _button.x = 100;
        _button.y = 100;
        _button.width = 50;
        _button.height = 20;
        _button.label = "ok";
        addChild(_button);

        _button = new ButtonLong(ButtonLong.GREEN_TYPE, true);
        _button.x = 100;
        _button.y = 200;
        _button.width = 250;
        _button.height = 80;
        _button.label = "test";
        addChild(_button);
    }
}

